<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加学院</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <div class="layui-input-inline">
        <!-- 使用隐藏域用于保存编辑项的ID值，便于提交修改 -->
            <input type="hidden" class="projectid" name="projectid" id="projectid">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-inline">
        <!-- 使用隐藏域用于保存编辑项的ID值，便于提交修改 -->
            <input type="hidden" class="arrangeid" name="arrangeid" id="arrangeid">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">报名人数</label>
      <div class="layui-input-inline">
        <input type="text" id="signup" value="" name="signup" readonly="true"  lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">分组人数</label>
      <div class="layui-input-inline">
        <input type="text" id="grouplimitnum" value="" name="grouplimitnum" lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
  </div>
  
 	<script src="../../js/jquery-3.3.1.js" charset="utf-8"></script>
	<script src="../../layui/layui.js" charset="utf-8"></script>
	<script src="../../js/loadselect.js" charset="utf-8"></script>
  <script>
 layui.config({
	    base: '../../layuiadmin/' //静态资源所在路径
	  }).extend({
	    index: 'lib/index' //主入口模块
	  }).use(['table','jquery','form'], function(){
	  var table = layui.table;
	  var $ = layui.jquery;
	  var form=layui.form;
	  
	  var projectidxxYXH = sessionStorage.getItem('projectidxxYXH');
	  var param ="?projectid="+projectidxxYXH
  	  $.ajax({
		    url:"../../grouping/getsigbypro"+ param,
		    type:"POST",
		    data:null,
		    dataType : "json",
		    xhrFields :{
		     withCredentials: true
		    },
		    contentType:'application/json;charset=UTF-8',
		    success:function(e){
		     if(e.code == 0){
		      	$("#signup").val(e.count);
		     }else{
		      	$("#signup").val(e.count);
		      return;
		     }
		     	     
		    },
		    error:function(e){
		     layer.msg("添加失敗",{icon:5});
		     
		    }
		   })
		   
    //监听提交
    form.on('submit(layuiadmin-app-form-submit)', function(data){
      var field = data.field; //获取提交的字段
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
      
	  var param ="?arrangeid="+field.arrangeid+"&projectid=" + field.projectid+"&grouplimitnum="+field.grouplimitnum;
	  console.log(param);
	  //提交 Ajax 成功后，关闭当前弹层并重载表格
      $.ajax({
		    url:"../../grouping/getgrouping"+ param,
		    type:"POST",
		    data:null,
		    dataType : "json",
		    xhrFields :{
		     withCredentials: true
		    },
		    contentType:'application/json;charset=UTF-8',
		    success:function(e){
		     if(e.code == 0){
		      layer.msg(e.msg,{icon:6}); 
		     }else{
		      layer.msg(e.msg,{icon:5});
		      return;
		     }
		     
		     setTimeout(function(){
		      parent.layui.table.reload('adminUser'); //重载表格
		           parent.layer.close(index); //再执行关闭 
		     },1*1000)
		     
		    },
		    error:function(e){
		     layer.msg(e.msg,{icon:5});
		     
		    }
		   })
		       return false;
		   
    });
  })
  </script>
   <script>
   
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //日期时间选择器
  laydate.render({
    elem: '#starttime'
    ,type: 'datetime'
    ,trigger : 'click'
  });
   //日期时间选择器
  laydate.render({
    elem: '#endtime'
    ,type: 'datetime'
    ,trigger : 'click'
  });
});
</script>
  
</body>
</html>